<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

</head>
<body>
    <div id="app">
        <div>请输入问题：<input type="text" v-model="question"></div>
        <div>答案：{{answer}}</div>

    </div>
    <script type="module">
        import {createApp, watch, ref} from './node_modules/vue/dist/vue.esm-browser.js'
        import debounce from './node_modules/lodash-es/debounce.js'

        createApp({
            setup() {
                let question = ref("")
                let answer = ref("")
                const getData = async () => {

                    let data =  await fetch('https://www.yesno.wtf/api')
                    answer.value = data.statusText
                  
                }
                watch(question,debounce(getData, 300))
              
                return {
                    question,
                    answer
                }
            }
        }).mount("#app");
    </script>
</body>
</html>